const TotalLanes = 31;
//无 0
const NoLanes = 0b0000000000000000000000000000000;
const NoLane = 0b0000000000000000000000000000000;
//同步车道
const SyncLane = 0b0000000000000000000000000000001;
//输入连续水合赛道
const InputContinuousHydrationLane = 0b0000000000000000000000000000010;
//输入连续车道
const InputContinuousLane = 0b0000000000000000000000000000100;//4
//默认水合车道
const DefaultHydrationLane = 0b0000000000000000000000000001000;
//默认车道
const DefaultLane = 0b0000000000000000000000000010000;//16
const TransitionHydrationLane = 0b0000000000000000000000000100000;
const TransitionLanes = 0b0000000001111111111111111000000;
const TransitionLane1 = 0b0000000000000000000000001000000;
const TransitionLane2 = 0b0000000000000000000000010000000;
const TransitionLane3 = 0b0000000000000000000000100000000;
const TransitionLane4 = 0b0000000000000000000001000000000;
const TransitionLane5 = 0b0000000000000000000010000000000;
const TransitionLane6 = 0b0000000000000000000100000000000;
const TransitionLane7 = 0b0000000000000000001000000000000;
const TransitionLane8 = 0b0000000000000000010000000000000;
const TransitionLane9 = 0b0000000000000000100000000000000;
const TransitionLane10 = 0b0000000000000001000000000000000;
const TransitionLane11 = 0b0000000000000010000000000000000;
const TransitionLane12 = 0b0000000000000100000000000000000;
const TransitionLane13 = 0b0000000000001000000000000000000;
const TransitionLane14 = 0b0000000000010000000000000000000;
const TransitionLane15 = 0b0000000000100000000000000000000;
const TransitionLane16 = 0b0000000001000000000000000000000;
const RetryLanes = 0b0000111110000000000000000000000;
const RetryLane1 = 0b0000000010000000000000000000000;
const RetryLane2 = 0b0000000100000000000000000000000;
const RetryLane3 = 0b0000001000000000000000000000000;
const RetryLane4 = 0b0000010000000000000000000000000;
const RetryLane5 = 0b0000100000000000000000000000000;
const SomeRetryLane = RetryLane1;
const SelectiveHydrationLane = 0b0001000000000000000000000000000;
const NonIdleLanes = 0b0001111111111111111111111111111;
const IdleHydrationLane = 0b0010000000000000000000000000000;
const IdleLane = 0b0100000000000000000000000000000;
const OffscreenLane = 0b1000000000000000000000000000000;

/**
 * 获取当前优先级最高的车道
 * @param {*} lanes 
 */
function getHighestPriorityLane(lanes) {
  return lanes & -lanes;
}
let a = 0b00011000;//16+8=24  -24
//0b11101000
//00011000
//11101000

console.log(getHighestPriorityLane(0b00011000));//1000=8

console.log(5 & -5);
//00000101 5
//10000101  -5原码
//11111010  -5反码
//11111011  -5补码
//00000101  5补码
//00000001  1

/**
 * 获取优先级最低的lane
 * 其实就是最左则的1
 * 31个lane+0=32
 * 整数是4个字节表示，一个字节是8位，32位
 * @param {*} lanes 
 */
function getLowestPriorityLane(lanes) {
  // 12
  //31-12=11110100001001000000长度=19
  const index = 31 - Math.clz32(lanes);
  return 1 << index;
}
const numA = 0b00000000000000000000000000001100;
console.log(getLowestPriorityLane(numA));//